<?php
// TODO UPDATE MEEEEE!!!!!!!!

	if ($_REQUEST['panel']=='pass') {
		$SITE_MIDDLE .= FormatElement( GetLangString($lang,"txt_changepwd"), 
			"<form method=\"POST\" ACTION=\"index.php?do=update\">".
			FormatSmallElement ( GetLangString($lang,"txt_password"), 
			"<input name='newpwd' type='password'>").
			FormatSmallElement ( GetLangString($lang,"txt_passagain"), 
			"<input name='again' type='password'>"). 
			"<input value=\"".GetLangString($lang,"txt_save")."\" name=\"upd_pwd\" type=\"submit\"></form>");
	} else

	if ($_REQUEST['panel']=='mail') {
		$SITE_MIDDLE .= " Changing Email Address Currently Disabled";
	} else 
				
				
	if ($_REQUEST['panel']=='info') {
		$items= array();
		$query        = "		SHOW COLUMNS FROM `info`";
		$result = mysql_query($query);
		while ($fields = mysql_fetch_array($result)) {
			if (!strncmp($fields['Type'],	"enum",3)) {
				$item = array ( $fields['Field'],GetEnum ("info",$fields['Field']));
				array_push($items,$item);
			}	
		}
		//print_r($infos);
		//die();
		$query        = "SELECT * from info where id='" . $id ."'";
		$result = mysql_query($query);
		$profileinfo = mysql_fetch_array($result);
		 	 	 	 		
		

		$info  = "<form method=\"POST\" ACTION=\"index.php?do=update\">";
	
		$bdayfrm = "<center><table style =\"padding: 0\" border=\"0\"><tr><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_day") , "<input value=\"".$profileinfo['day']."\" name=\"day\" maxlenght=\"2\">").
		"</td><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_month") , "<input value=\"".$profileinfo['month']."\" name=\"month\" maxlenght=\"2\">").
		"</td><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_year") , "<input value=\"".$profileinfo['year']."\"  name=\"year\" maxlenght=\"4\">").
		"</td></tr></table></center>";
		
	
		$info .= FormatSmallElement ( GetLangString ( $lang, "txt_bday") , $bdayfrm);
		foreach ($items as $item) {
			$options = "<select size=\"1\" name=\"". $item[0] . "\">";
			foreach ($item[1] as $option) {
				$options .= "<option value=\"$option\" name=\"". $item[0] ."\"";
				if ($profileinfo[$item[0]]==$option) $options .= " selected ";
				$options .= ">". GetLangString ($lang, $option) . "</option>"; 
			}
			$options .= "</select>";
			$info .= FormatSmallElement ( GetLangString ( $lang, "txt_". $item[0]) , $options);
		}

		$info .= "					<input value=\"".GetLangString($lang,"txt_save") ."\" name=\"upd_info\" type=\"submit\"></form>";
		$SITE_MIDDLE .= FormatElement ( GetLangString ($lang, "txt_personalinfo"),$info);


					/*
					$SITE_MIDDLE .= "
					<div class=profileelement><div class=label>Personal Info</div><form method=\"POST\" ACTION=\"index.php?do=update\">
					<label>Birthday:</label><br><input type=\"text\" name=\"bday\" value=\"".$profileinfo[bday] ."\">
                
                
                <label>Gender:</label><br>
                <select name=\"Gender\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Gender]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">N/A</option>
									<option value='male'";
									if ($profileinfo[Gender]=='male') $SITE_MIDDLE .=" selected " ; 
									$SITE_MIDDLE .=">male</option>
									<option value='female'";
									if ($profileinfo[Gender]=='female') $SITE_MIDDLE .=" selected " ; 
									$SITE_MIDDLE .=	">female</option>
									<option value='male-to-female'	";
									if ($profileinfo[Gender]=='male-to-female') $SITE_MIDDLE .= " selected " ; 
									$SITE_MIDDLE .=">male-to-female</option>
									<option value='female-to-male'	";
									if ($profileinfo[Gender]=='female-to-male') $SITE_MIDDLE .=" selected " ;
									$SITE_MIDDLE .= ">female-to-male</option>
								</select>
								<label>Orientation:</label><br>
								<select name=\"Orientation\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Orientation]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=	">N/A</option>
									<option value='bi'";
									if ($profileinfo[Orientation]=='bi') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">bi</option>
									<option value='gay'					";
									if ($profileinfo[Orientation]=='gay') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">gay</option>
									<option value='straight'	";
									if ($profileinfo[Orientation]=='straight') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">straight</option>
									<option value='not sure'	";
									if ($profileinfo[Orientation]=='not sure') $SITE_MIDDLE .= " selected "; 
								$SITE_MIDDLE .=">not sure</option>
								</select>
								<label>Status:</label><br>
								<select name=\"Status\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Status]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">N/A</option>
								
									<option value='single'";
									if ($profileinfo[Status]=='single') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">single</option>
									
									<option value='in relationship'					";
									if ($profileinfo[Status]=='in relationship') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">in relationship</option>
									
									<option value='open relationship'	";
									if ($profileinfo[Status]=='open relationship') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">open relationship</option>
									
									<option value='married'	";
									if ($profileinfo[Status]=='married') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">married</option>
									
									<option value='partnership'	";
									if ($profileinfo[Status]=='partnership') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">partnership</option>
								</select>
								<label>Drink:</label><br>
								<select name=\"Drink\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Drink]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">N/A</option>
									<option value='never'";
									if ($profileinfo[Drink]=='never') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">never</option>
									<option value='occasionally'					";
									if ($profileinfo[Drink]=='occasionally') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">occasionally</option>
									<option value='often'	";
									if ($profileinfo[Drink]=='often') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">often</option>
								</select>
								<label>Smoke:</label><br>
																<select name=\"Smoke\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Smoke]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">N/A</option>
									<option value='never'";
									if ($profileinfo[Smoke]=='never') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">never</option>
									<option value='occasionally'					";
									if ($profileinfo[Smoke]=='occasionally') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">occasionally</option>
									<option value='often'	";
									if ($profileinfo[Smoke]=='often') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">often</option>
								</select>
									<label>Drugs:</label><br>
								<select name=\"Drugs\" size=\"1\">
									<option value='N/A'";
									if ($profileinfo[Drugs]=='N/A') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">N/A</option>
									<option value='never'";
									if ($profileinfo[Drugs]=='never') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">never</option>
									<option value='occasionally'					";
									if ($profileinfo[Drugs]=='occasionally') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">occasionally</option>
									<option value='often'	";
									if ($profileinfo[Drugs]=='often') $SITE_MIDDLE .= " selected "; 
									$SITE_MIDDLE .=">often</option>
								</select>

								
					
					<input value=\"Save\" name=\"upd_info\" type=\"submit\">
					</div>";
					*/
					
	} else 
				
				
	if ($_REQUEST['panel']=='profile') {
		$query        = "SELECT * from profile where id='" . $id ."'";
		$result 			= mysql_query($query);
		$profileinfo 	= mysql_fetch_array($result);
				
		$about 		= html2text($profileinfo['about']);
		$like	 		=	html2text($profileinfo['turnon']);
		$dislike	= html2text($profileinfo['turnoff']);
		$music		= html2text($profileinfo['music']);
		$film			= html2text($profileinfo['film']);
		$book			= html2text($profileinfo['book']);
					
		$SITE_MIDDLE .= 
		FormatElement ( GetLangString ($lang, "txt_profiletext") , 
		"<form method=\"post\" action=\"/index.php?do=update\">".
		FormatSmallElement ( GetLangString ($lang, "txt_about"),
		"<textarea name=\"about\" rows=\"5\">$about</textarea>").
		FormatSmallElement ( GetLangString ($lang, "txt_like"),
		"<textarea name=\"like\" rows=\"5\">$like</textarea>").
		FormatSmallElement ( GetLangString ($lang, "txt_dislike"),
		"<textarea name=\"dislike\" rows=\"5\">$dislike</textarea>").
		FormatSmallElement ( GetLangString ($lang, "txt_music"),
		"<textarea name=\"music\" rows=\"5\">$music</textarea>").
		FormatSmallElement ( GetLangString ($lang, "txt_film"),
		"<textarea name=\"film\" rows=\"5\">$film</textarea>").
		FormatSmallElement ( GetLangString ($lang, "txt_book"),
		"<textarea name=\"book\" rows=\"5\">$book</textarea>").
		"<input value=\"".GetLangString($lang,"txt_save")."\" name = \"upd_profile\" 	type=\"submit\"></form>");
	} else {

		$SITE_MIDDLE .=  FormatSmallElement ( GetLangString ($lang, "txt_personalpage") , 
		"<center><table border=\"0\" width=\"75%\"><tr><td align=\"center\" valign=\"top\" width=\"50%\">". 
		FormatLink(GetLangString($lang,"txt_photoupload"),	GetLangString($lang,"msg_photoupload"),		"index.php?do=photoupload").
		FormatLink(GetLangString($lang,"txt_photomanager"),	GetLangString($lang,"msg_photomanager"),	"index.php?do=photomanager").
		FormatLink(GetLangString($lang,"txt_friendmanager"),	str_ireplace("%number%",CountFriendRequests(),GetLangString($lang,"msg_friendmanager")),	"index.php?do=friends").
		FormatLink(GetLangString($lang,"txt_sessionmanager"),	GetLangString($lang,"msg_sessionmanager"),	"index.php?do=session").
		FormatLink(GetLangString($lang,"txt_thememanager"),	GetLangString($lang,"msg_thememanager"),	"index.php?do=usertheme").
		"</td><td align=\"center\"  valign=\"top\">".			
		FormatLink(GetLangString($lang,"txt_personalinfo"),	GetLangString($lang,"msg_personalinfo"),	"index.php?do=control&panel=info").
		FormatLink(GetLangString($lang,"txt_profiletext"),	GetLangString($lang,"msg_profiletext"),		"index.php?do=control&panel=profile").
		FormatLink(GetLangString($lang,"txt_changepwd"),	GetLangString($lang,"msg_changepwd"),		"index.php?do=control&panel=pass").
		FormatLink(GetLangString($lang,"txt_externalmanager"),	GetLangString($lang,"msg_externalmanager"),	"index.php?do=external").
		"</td></tr></table></center>");
	}
?>
